package com.admin.business.personalCenter.venusSysUserInvitation;

import com.tiangong.framework.annotation.OpenApi;
import com.tiangong.framework.bo.CDO;
import com.tiangong.framework.bo.Return;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

/**
 * @description: 加盟商邀请记录表
 * @create: 2023-11-23 14:59:29
 **/
@Service("venusSysUserInvitationService")
@Slf4j
public class VenusSysUserInvitationService{

    @Resource
    VenusSysUserInvitationDao venusSysUserInvitationDao;

    /**
     * 添加加盟商邀请记录表,获取id数据
     *
     * @param cdoRequest - id:主键
     *                   - userId:邀请用户ID
     *                   - invitationNumber:绑定邀请码
     *                   - invitationMoney:充值金额
     *                   - invitationIncome:收入金额
     *                   - organizeName:公司名称
     *                   - invitationStates:邀请金额状态：0、冻结中，1、已解冻
     *                   - paymentStates:支付状态：0、未支付，1、已支付
     *                   - beginTime:创建时间
     *                   - updateTime:更新时间
     *                   - state:是否删除：0、正常，1、已删除；
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return addVenusSysUserInvitation(CDO cdoRequest) {
        venusSysUserInvitationDao.addVenusSysUserInvitation(cdoRequest);
        CDO cdoResult = new CDO();
        if (cdoRequest.containsKey("id")) {
            cdoResult.set("id", cdoRequest.get("id"));
        }
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据id，更新加盟商邀请记录表数据
     *
     * @param cdoRequest - id:主键
     *                   - userId:邀请用户ID
     *                   - invitationNumber:绑定邀请码
     *                   - invitationMoney:充值金额
     *                   - invitationIncome:收入金额
     *                   - organizeName:公司名称
     *                   - invitationStates:邀请金额状态：0、冻结中，1、已解冻
     *                   - paymentStates:支付状态：0、未支付，1、已支付
     *                   - beginTime:创建时间
     *                   - updateTime:更新时间
     *                   - state:是否删除：0、正常，1、已删除；
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return updateVenusSysUserInvitationById(CDO cdoRequest) {
        venusSysUserInvitationDao.updateVenusSysUserInvitationById(cdoRequest);
        return Return.SUCCESS;
    }

    /**
     * 根据id，删除加盟商邀请记录表数据
     *
     * @param cdoRequest - id:主键
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return deleteVenusSysUserInvitationById(CDO cdoRequest){
        int count = venusSysUserInvitationDao.deleteVenusSysUserInvitationById(cdoRequest.getString("id"));
        CDO cdoResult = new CDO();
        cdoResult.set("count", count);
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据条件，删除加盟商邀请记录表数据
     *
     * @param cdoRequest
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return deleteVenusSysUserInvitation(CDO cdoRequest) {
        int count = venusSysUserInvitationDao.deleteVenusSysUserInvitation(cdoRequest);
        CDO cdoResult = new CDO();
        cdoResult.set("count", count);
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据ID，获取加盟商邀请记录表数据
     *
     * @param cdoRequest - id:主键
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return getVenusSysUserInvitationById(CDO cdoRequest) {
        CDO cdoMapperResult = venusSysUserInvitationDao.getVenusSysUserInvitationById(cdoRequest.getString("id"));
        return Return.valueOf(cdoMapperResult);
    }

    /**
     * 根据非空条件，获取加盟商邀请记录表数据列表
     *
     * @param cdoRequest
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return getVenusSysUserInvitationListPage(CDO cdoRequest) {
        Integer pageIndex = cdoRequest.getInteger("pageIndex")-1;
        int recordSize = 10;
        cdoRequest.set("recordFrom", pageIndex * recordSize);
        cdoRequest.set("recordSize", recordSize);
        List<CDO> cdoMapperResultList = venusSysUserInvitationDao.getVenusSysUserInvitationListPage(cdoRequest);
        boolean isEndPage = false;
        if (cdoMapperResultList.size() < recordSize) {
            isEndPage = true;
        }
        CDO cdoResult = new CDO();
        cdoResult.set("isEndPage", isEndPage);
        cdoResult.set("datalist", cdoMapperResultList);
//        int total = venusSysUserInvitationDao.getVenusSysUserInvitationCount(cdoRequest);
//        cdoResult.set("total", total);
        return Return.valueOf(cdoResult);
    }
    /**
     * 根据混合条件，获取加盟商邀请记录表数据列表
     *
     * @param cdoRequest - id:主键
     * @return
     * @author wdf
     * @create: 2023-11-23 14:59:29
     */
    @OpenApi
    public Return getVenusSysUserInvitationListPageByCondition(CDO cdoRequest) {
        Integer pageIndex = cdoRequest.getInteger("pageIndex")-1;
        int recordSize = 10;
        cdoRequest.set("recordFrom", pageIndex * recordSize);
        cdoRequest.set("recordSize", recordSize);
        List<CDO> cdoMapperResultList = venusSysUserInvitationDao.getVenusSysUserInvitationListPageByCondition(cdoRequest);
        boolean isEndPage = false;
        if (cdoMapperResultList.size() < recordSize) {
            isEndPage = true;
        }
        CDO cdoResult = new CDO();
        cdoResult.set("isEndPage", isEndPage);
        cdoResult.set("datalist", cdoMapperResultList);
//        int total = venusSysUserInvitationDao.getVenusSysUserInvitationCount(cdoRequest);
//        cdoResult.set("total", total);
        return Return.valueOf(cdoResult);
    }
}
